export function errorText(err: unknown): string {
  const messages = [];

  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  for (let e = err as any; e; e = e.internalError) {
    if (e.stack) {
      messages.push(e.stack);
    } else if (e.message) {
      messages.push(e.message);
    } else {
      messages.push(String(e));
    }
  }

  return messages.join('---');
}
